/*  File Name	: GateService.h
 *  Author		: Javie Pong
 *	 E-mail		: 823960168@qq.com
 *  Created on	: 2012-7-1
 *  Description:
 */

#ifndef GATESERVICE_H_
#define GATESERVICE_H_
#include "Service.h"

class GateMonitor;

class GateService:virtual public ServiceEX<GateMonitor>
{
private:
	typedef  ServiceEX<GateMonitor> super;

public:
	GateService(int p=0);

	virtual ~GateService();

	virtual int open(void * =0);

	virtual int handle_input(int  fd = INVALID_HANDLER);

	virtual int handle_output(int fd = INVALID_HANDLER);

	virtual int handle_timeout(void);

	virtual int handle_close(int handle = INVALID_HANDLER,
			ReactorMask = EventHandler::ALL_MASK);

	//int recycle(GateService *s);

	virtual int recv_msg(const int limit_size = 1024*60);

	void reset(void);

	std::string name(void);

	const int role_id(void);
	void role_id(int role_id);

	bool is_engine(void);
	void set_engine(void);

	bool is_dircserver(void);
	void set_dircsever(void);

	bool is_dbsever(void);
	void set_dbesver(void);

private:
	int is_flash_sanbox(MessageBlock *mb);

	int role_id_;
	int exception_;
	bool is_engine_;
	bool is_dircserver_;
	bool is_dbsever_;
};

#endif /* GATESERVICE_H_ */
